<?php
	include_once "db_connect.php";

	//====================================================
	// 후기 리스트 가져오기
	//====================================================
	
	// 스타 오늘의 운세는 리스트 갯수가 다름.
	if ($_SERVER['REQUEST_URI'] == '/unse/star/todaybirth/main'
		|| $category['method'] == 'result'
		) {
		$page_size = 3;
	} else {
		$page_size = 4;
	}
	
	// 쿼리문 작성
	$sql  = " SELECT ";
	$sql .= "       B.idx ";
	$sql .= "     , B.category ";
	$sql .= "     , B.user_id ";
	$sql .= "     , B.nickname ";
	$sql .= "     , B.service_id ";
	$sql .= "     , S.service_url ";
	$sql .= "     , S.service_name ";
	$sql .= "     , (SELECT service_group_name FROM tb_service_group WHERE service_group_id = S.service_group_id) service_group_name ";
	$sql .= "     , B.subject ";
	$sql .= "     , B.content ";
	$sql .= " FROM  tb_bbs B ";
	$sql .= " JOIN  tb_service S ON B.service_id = S.service_id ";
	$sql .= " WHERE 1=1 ";
	$sql .= " AND   category = 'postscript' ";
	$sql .= " AND   B.notice_yn = 'N' ";
	$sql .= " ORDER BY B.create_dt DESC ";
	$sql .= " LIMIT 0, $page_size ";
	
	$postscript_list = query_to_array($sql);
	
	// 썸네일 이미지 파일명
	$ps_thumb = array(
		  'star_todaybirth'   => 'sum_star_86.jpg'
		, 'star_gunghap'      => 'sum_star_86.jpg'
		, 'money_mymoney'     => 'sum_money_86.jpg'
		, 'money_gunghap'     => 'sum_money_86.jpg'
		, 'saju_total'        => 'sum_saju_86.jpg'
		, 'tojung_total'      => 'sum_tog_86.jpg'
		, 'gunghap_mylover'   => 'sum_gh_86.jpg'
		, 'gunghap_sintong'   => 'sum_gh_86.jpg'
		, 'gunghap_style'     => 'sum_gh_86.jpg'
		, 'adult_total'       => 'sum_sex_86.jpg'
		, 'free_today'        => 'sum_today_86.jpg'
		, 'theme_business'    => 'sum_theme_86.jpg'
		, 'theme_joint'       => 'sum_theme_86.jpg'
		, 'theme_children'    => 'sum_theme_86.jpg'
		, 'theme_savemoney'   => 'sum_theme_86.jpg'
		, 'theme_defendmoney' => 'sum_theme_86.jpg'
		, 'theme_moneytech'   => 'sum_theme_86.jpg'
		, 'theme_subordinate' => 'sum_theme_86.jpg'
		, 'theme_boss'        => 'sum_theme_86.jpg'
	);
?>
			<div class="board">
				<div class="tit">
					<h3><img src="/images/main/tit_board.gif" /></h3>
					<span class="more"><a href="/bbs/postscript">더보기</a></span>
				</div>
				<ul class="review">
					<li>
						<a href="/bbs/postscript/read?idx=<?=$postscript_list[0]['idx']?>"class="img"><img src="/images/common/sum/<?=$ps_thumb[$postscript_list[0]['service_id']]?>" align="absmiddle"  /></a>
						<span class="txt1"><a href="/bbs/postscript/read?idx=<?=$postscript_list[0]['idx']?>">[<?=substr($postscript_list[0]['service_id'],0,4)=='free' ? '무료운세' : $postscript_list[0]['service_name']?>]</a> </span>
						<span class="txt2"><a href="/bbs/postscript/read?idx=<?=$postscript_list[0]['idx']?>"><?=$postscript_list[0]['nickname']?></a></span>
						<span class="txt3"><a href="/bbs/postscript/read?idx=<?=$postscript_list[0]['idx']?>"><?=mb_strlen($postscript_list[0]['subject'], 'utf-8') > 10 ? mb_substr($postscript_list[0]['subject'], 0, 10, 'utf-8').'..' : $postscript_list[0]['subject']?></a></span>
					</li>
<?
	$cnt = count($postscript_list);
	for ($i=1; $i < $cnt; $i++) {
		$item = $postscript_list[$i];
?>
					<li class="list <?=$i == $cnt-1 ? 'end' : ''?>"><a href="/bbs/postscript/read?idx=<?=$item['idx']?>"><?=mb_strlen($item['subject'], 'utf-8') > 14 ? mb_substr($item['subject'], 0, 14, 'utf-8').'..' : $item['subject']?></a> <span class="txt4"><?=$item['nickname']?></span></li>
<?	} ?>
				</ul>
			</div>
